<?php
/**
 * @author Tibor Pino (tibor.pino@gmail.com)
 * @license released under GNU Public License v. 2
 * @copyright Copyright (c) 2007, Tibor Pino
 *
 */

class RatingHelper extends AppHelper {
    
    public function get_rating($data) {
        $good = 0;
        $counter = count($data);

        if($counter>0) {
            foreach ($data as $rating) {
                if($rating['value']==1) $good++;
            }
            $percent = intval(100/$counter*$good);
            return $this->output($percent);
        } else {
            return $this->output(0);
        }
    }

    public function amount($data) {
        return $this->output(count($data));
    }
}
?>